iT邦幫忙

2023 iThome 鐵人賽

DAY 19
0

這篇要介紹的是如何透過 Makefile to combine command line. In the meantime, show how to integrate with terraform and cdk8s command.

前面提到了一些 MLE 的部分,除了 Basic Knowledge 是 Machine Learning 之外,其實對一個 MLE 來講,其他的 Ops 的工具相對來講都是比較陌生的地方。

  • Terraform
  • CDK8s
  • K8s
  • AWS
  • Gitlab CI

以上敘述的這幾樣東西我相信基本上 8 成的 Machine Learning Engineer 不太會使用到,甚至接觸到,因此對於要怎麼把這些東西整合再一起,把同時接觸的東西整合再一起是很困難的事情。更對一個新手而言,其實更困難

更為令人難過的是,你還要會使用它,不可能一直都去查 document 去看之前是怎麼使用的,所以礙於本人腦容量缺乏的關係,所以都會用 makefile 把有需要的資訊都串連再一起,就是怕自己哪天忘記,看一下 makefile 也知道整個指令要怎麼下。

Brief introduction Makefile

協助下 command 的工具,同時也可以設置 Variable 的功能在 script 中,因此可以串一些 Variable 到 command 一起帶入。

而為什麼會需要帶 Variable 的話就是前幾天提到的 一些敏感性的資料要把它丟到變數,而多數的人也沒辦法手動直接輸入那些 Variable ,因為 Variable 的部分可能是一些 Token 不一定是數值或者字詞。而當然也可以使用 Environment 的部分把 Variable 資訊記錄下來

因此就是要把一些一大串的 Command 使用一個 Script 把整串記錄起來,因為這樣打錯也比較好去 Track back 是哪些地方錯誤了

另外 Makefile 也有很強大的功能就是可以做 dependency ,因為以 Docker 來講,可能會先做 docker build 然後再來 docker tag 最後要 push 到 repository 的 docker push 這樣串起來就可以設定 要執行 push 之前先執行tag ,然後執行tag 之前要執行 build 。

What things makefile can help?

這邊就舉幾個常見的使用情境

  • Authorized docker hub and build image, then push to ducker
  • Compile program and push to git server
  • similar gitlab ci flow to execute the ci procedure
  • build cdk8s and then deploy to k8s cluster
  • Execute serval functionality command by fellow those sequence.

這幾個共通點就是 常常碰到,而且每碰到都要執行很多次,然候指令又特別多又要帶很多參數進去

Notice: Add makefile to gitigonre

這邊要記得把 makefile 的部分加進去 .gitignore ,因為 makefile 上面可能會存放自己的 敏感資訊, 因此要記得不要丟到 gitlab 上面,不然不小心 git push 之後大家都會知道你的秘密。

而makefile 範例的部分則是會在下一篇最示範


上一篇
{Day 18: Allocate nodes to each situations}
下一篇
{Day 20: build docker image to ECR}
系列文
Don't be a Machine Learning Engineer30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言